import { axios } from '@/utils/request'

const api = {
  listFormulaLine: '/validate/formula/line/list',
  queryFormulaWithLine: '/validate/formula/queryWithLineAndParam',
  saveFormula: '/validate/formula/save',
  setFormulaEnable: '/validate/formula/changeEnabled'
}
export function listFormulaLines (params) {
  return axios({
    url: api.listFormulaLine,
    params: params,
    method: 'get'
  })
}
export function saveFormula (data) {
  return axios({
    url: api.saveFormula,
    data: data,
    method: 'post'
  })
}

export function queryFormulaWithLines (params, pageNum, pageSize) {
  if (!params) {
    params = {}
  }
  params.pageNum = pageNum
  params.pageSize = pageSize
  return axios({
    url: api.queryFormulaWithLine,
    params: params,
    method: 'get'
  })
}

export function deleteFormula (id) {
  return axios({
    url: `/validate/formula/delete/${id}`,
    method: 'delete'
  })
}

export function setFormulaEnable (data) {
  return axios({
    url: api.setFormulaEnable,
    data: data,
    method: 'post'
  })
}
